home *** CD-ROM | disk | FTP | other *** search
- Path: news.tp.ac.com!news
- From: Asgeir Olafsson <olafsson@cstar.ac.com>
- Newsgroups: comp.lang.c++
- Subject: A question of privacy
- Date: Fri, 19 Apr 1996 15:18:28 -0500
- Organization: Andersen Consulting
- Message-ID: <3177F514.544E@cstar.ac.com>
- NNTP-Posting-Host: cstar51060.tp.ac
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Should the following work according to the ANSI C++
- standard draft?
-
- // Compiles fine under VC++ 4.0
- class A {
- private:
- A() {}
- };
-
- class B {
- public:
- A &f() { return A();} // No complaints about privacy
- };
-
- void g()
- {
- B b;
- A a = b.f();
- }
-
-
- I suspect what is happening, is that a temporary object
- is being created, so if this is legal the object could be
- deleted as soon as "a" goes out of scope?
-
- Regards,
- 'Asgeir.
-